<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title>Edit Devicegroup</title>
</head>
<body>
<div class="nav">
    <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}">Home</a></span>
    <span class="menuButton"><g:link class="list" action="list">Devicegroup List</g:link></span>
    <span class="menuButton"><g:link class="create" action="create">New Devicegroup</g:link></span>
</div>
<div class="body">
    <h1>Edit Devicegroup</h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${devicegroup}">
        <div class="errors">
            <g:renderErrors bean="${devicegroup}" as="list"/>
        </div>
    </g:hasErrors>
    <g:form method="post">
        <input type="hidden" name="id" value="${devicegroup?.id}"/>
        <div class="dialog">
            <table>
                <tbody>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="notifyAction">Notify Action:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'notifyAction', 'errors')}">
                            <g:select id="notifyAction" name="notifyAction" from="${devicegroup.constraints.notifyAction.inList.collect{it.encodeAsHTML()}}" value="${fieldValue(bean:devicegroup,field:'notifyAction')}"></g:select>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="speedUnits">Speed Units:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'speedUnits', 'errors')}">
                            <g:select id="speedUnits" name="speedUnits" from="${devicegroup.constraints.speedUnits.inList.collect{it.encodeAsHTML()}}" value="${fieldValue(bean:devicegroup,field:'speedUnits')}"></g:select>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="geocoderMode">Geocoder Mode:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'geocoderMode', 'errors')}">
                            <g:select id="geocoderMode" name="geocoderMode" from="${devicegroup.constraints.geocoderMode.inList.collect{it.encodeAsHTML()}}" value="${fieldValue(bean:devicegroup,field:'geocoderMode')}"></g:select>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="dateCreated">Date Created:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'dateCreated', 'errors')}">
                            <g:datePicker name="dateCreated" value="${devicegroup?.dateCreated}"></g:datePicker>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="description">Description:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'description', 'errors')}">
                            <input type="text" id="description" name="description" value="${fieldValue(bean: devicegroup, field: 'description')}"/>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="devices">Devices:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'devices', 'errors')}">

                            <ul>
                                <g:each var="d" in="${devicegroup?.devices?}">
                                    <li><g:link controller="device" action="show" id="${d.id}">${d}</g:link></li>
                                </g:each>
                            </ul>
                            <g:link controller="device" params="[" devicegroup.id":devicegroup?.id]" action="create">Add Device</g:link>

                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="geozones">Geozones:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'geozones', 'errors')}">

                            <ul style="float:left;border: medium double rgb(250,0,255); ">
                                <g:each var="g" in="${devicegroup?.geozones?}">
                                    <li><g:link controller="geozone${g.zoneType}" action="show" id="${g.id}">Show ${g.zoneType}: ${g.description} </g:link></li>
                                </g:each>
                            </ul>
                            <ul style="float:left;border: medium double rgb(250,0,255);">
                            <li><g:link controller="geozoneCircle" id="${devicegroup.id}" action="create">Add geozoneCircle</g:link></li>
                            <li><g:link controller="geozoneRectangle" id="${devicegroup.id}" action="create">Add geozoneRectangle</g:link></li>
                            <li><g:link controller="geozoneTriangle" id="${devicegroup.id}" action="create">Add geozoneTriangle</g:link></li>
                            <li><g:link controller="geozonePolygon" id="${devicegroup.id}" action="create">Add geozonePolygon</g:link></li>
                            </ul>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="lastUpdated">Last Updated:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'lastUpdated', 'errors')}">
                            <g:datePicker name="lastUpdated" value="${devicegroup?.lastUpdated}"></g:datePicker>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="maxDormantTime">Max Dormant Time:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'maxDormantTime', 'errors')}">
                            <input type="text" id="maxDormantTime" name="maxDormantTime" value="${fieldValue(bean: devicegroup, field: 'maxDormantTime')}"/>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="maxSpeed">Max Speed:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'maxSpeed', 'errors')}">
                            <input type="text" id="maxSpeed" name="maxSpeed" value="${fieldValue(bean: devicegroup, field: 'maxSpeed')}"/>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="minSpeed">Min Speed:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'minSpeed', 'errors')}">
                            <input type="text" id="minSpeed" name="minSpeed" value="${fieldValue(bean: devicegroup, field: 'minSpeed')}"/>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="name">Name:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'name', 'errors')}">
                            <input type="text" id="name" name="name" value="${fieldValue(bean: devicegroup, field: 'name')}"/>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="notifyEmailOrPhone">Notify Email Or Phone:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'notifyEmailOrPhone', 'errors')}">
                            <input type="text" id="notifyEmailOrPhone" name="notifyEmailOrPhone" value="${fieldValue(bean: devicegroup, field: 'notifyEmailOrPhone')}"/>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="toNotifyDormantOverMaxTime">To Notify Dormant Over Max Time:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'toNotifyDormantOverMaxTime', 'errors')}">
                            <g:checkBox name="toNotifyDormantOverMaxTime" value="${devicegroup?.toNotifyDormantOverMaxTime}"></g:checkBox>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="toNotifyOverspeed">To Notify Overspeed:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'toNotifyOverspeed', 'errors')}">
                            <g:checkBox name="toNotifyOverspeed" value="${devicegroup?.toNotifyOverspeed}"></g:checkBox>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="user">User:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: devicegroup, field: 'user', 'errors')}">
                            <g:select optionKey="id" from="${User.list()}" name="user.id" value="${devicegroup?.user?.id}"></g:select>
                        </td>
                    </tr>

                </tbody>
            </table>
        </div>
        <div class="buttons">
            <span class="button"><g:actionSubmit class="save" value="Update"/></span>
            <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete"/></span>
        </div>
    </g:form>
</div>
</body>
</html>
